import { Inject, Injectable, Scope } from '@nestjs/common';
import { REQUEST } from '@nestjs/core';
import { Request } from 'express';

@Injectable({ scope: Scope.REQUEST })
export class ReqProvider {

  get req(): Request {
    return this._req
  }

  get domain(): string {
    return `${this._req.protocol || "https"}://${this._req.hostname}`
  }

  constructor(@Inject(REQUEST) private readonly _req: Request) {}
}